
package ProOF.apl.problems.real.operators;
import ProOF.apl.problems.real.RealCodification;
import ProOF.apl.problems.real.RealProblem;
import ProOF.com.LinkerParameters;
import ProOF.gen.operator.oCrossover;

/**
 *
 * @author Hossomi
 */
public class RealCrossBLX extends oCrossover<RealProblem, RealCodification> {

	protected double alpha;
	
    @Override
    public String name() {
        return "BLXAlpha";
    }

    @Override
    public void parameters(LinkerParameters win) throws Exception {
    	// TODO Auto-generated method stub
    	super.parameters(win);
    	alpha = win.Dbl( "BLX-alpha", 0.5, 0, 1 );
    	
    }
    
    @Override
    public RealCodification crossover(RealProblem prob, RealCodification ind1, RealCodification ind2) throws Exception {
        RealCodification child = ind1.New(prob);
        for (int i = 0; i < prob.func.dimension(); i++) {
            child.x[i] = prob.rmd.nextDouble(ind1.x[i]*alpha, ind2.x[i]*alpha);;
        }
        prob.func.adjust(child.x);
        return child;
    }

}
